import requests
from common.file_load import load_yaml_file
import paths_manager

class RequestClient:
    session = requests.session()

    def __init__(self):
        # 重写属性 真实神奇，原来是 子类属性->父类属性，现在子类属性-> （父类属性+ 子类属性）
        self.params = None
        self.files = None
        self.resp = None
        self.json = None
        self.method = None
        self.headers = None
        self.url = None
        self.data = None
        self.resp = None

    def send(self):
        self.resp = RequestClient.session.request(method=self.method,
                                                  url=self.url,
                                                  headers=self.headers,
                                                  params=self.params,
                                                  data=self.data,
                                                  json=self.json,
                                                  files=self.files,
                                                  verify=False)

        return self.resp


class BuyerApi(RequestClient):

    def __init__(self):
        super().__init__()
        host = load_yaml_file(paths_manager.mtxshop_data_yaml)
        self.host = '129.0.0.1'
        self.headers = {
            'Authorization': 'Bear' + 'token'
        }


class SellerApi(RequestClient):

    def __init__(self):
        super().__init__()
        self.host = '129.0.0.2'
        self.headers = {
            'Authorization': 'Bear' + 'token2'
        }


class AddCartApi(BuyerApi):

    def __init__(self):
        super().__init__()
        self.method = 'post'
        self.url = f'{self.host}/addCart'
        self.data = None
        self.json = {

        }


class CreateOrderApi(BuyerApi):

    def __init__(self):
        super().__init__()
        self.method = 'post'
        self.url = f'{self.host}/createOrder'
        self.data = {

        }


class addGoodsApi(SellerApi):

    def __init__(self):
        super().__init__()
        self.method = 'POST'
        self.url = f'{self.host}/createOrder'
        self.data = {

        }


class aduitGoodsApi(SellerApi):

    def __init__(self):
        super().__init__()
        self.method = 'POST'
        self.url = f'{self.host}/createOrder'
        self.json = {

        }
